import { NgModule, ModuleWithProviders, Optional, SkipSelf } from '@angular/core';
import { HttpModule, JsonpModule } from '@angular/http';

import { PlayerService } from '../http/http-player.service';
import { AuthService } from '../auth.service';
import { DialogService } from '../dialog.service';

import { AuthGuard } from '../auth-guard.service';
import { CanDeactivateGuard } from '../can-deactivate-guard.service';

@NgModule({
    providers: [],
    exports: [HttpModule, JsonpModule]
})
export class ShareServiceModule {
    static forRoot(): ModuleWithProviders {
        return {
            ngModule: ShareServiceModule,
            providers: [
                PlayerService, AuthService, DialogService, AuthGuard, CanDeactivateGuard
            ]
        };
    }
    constructor( @Optional() @SkipSelf() parentModule: ShareServiceModule) {
        if (parentModule) {
            throw new Error(
                'CoreModule is already loaded. Import it in the AppModule only');
        }
    }
}
